# -*- coding: utf-8 -*-
import os

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QDockWidget, QAction, QFileDialog
from device.video.videoDevGui import *
import cv2

START_PATH = os.path.dirname(__file__)


class VideoDev(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.__class__.Icon = os.path.join(START_PATH, "icons/image.png")
        self.__class__.MenuText = "Video"
        self.__class__.ToolTip = "a video workbench"

    def setPlatform(self, platform):
        self.platform = platform

    def Initialize(self, index, para):
        self.app = videoDevGui()
        self.app.initUI()
        self.app.setPara(index, para)
        self.app.setFunctionName(self.__class__.MenuText)
        self.app.update_para_signal.connect(self.platform.updateRunPara)
        self.platform.moduleWidget.setWidget(self.app)

    def DeInitialize(self):
        self.app.update_signal.disconnect()

    def initRunEnv(self):
        self.app = videoDevGui()
        self.app.update_signal.connect(self.platform.updateImage)

    def run(self, para):
        self.app.run(para)

    def stop(self):
        self.platform.sayGoodbye("plugin2")


def getModuleClass():
    return VideoDev
